package cn.wolfcode.p2p.base.controller;

import cn.wolfcode.p2p.Exception.CustomException;
import cn.wolfcode.p2p.base.service.ILoginInfoService;
import cn.wolfcode.p2p.util.JSONResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class RegisterController {
    @Autowired
    private ILoginInfoService loginInfoService;

    /**
     * 注册
     *
     * @param username   用户名即手机号
     * @param confirmPwd 手机验证码
     * @param password   密码
     * @param verifycode 确认密码
     * @return
     */
    @RequestMapping("/userRegister")
    @ResponseBody
    public Object register(String username, String confirmPwd, String password, String verifycode) {
        loginInfoService.register(username,verifycode , password, confirmPwd);
        return JSONResultUtil.jsonResult();
    }

    @RequestMapping("/existUsername")
    @ResponseBody
    public boolean existUsername(String username) {
        return !loginInfoService.existUsername(username);
    }



}
